package flc.ast.adapter;

import android.graphics.Color;
import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyCutBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class CutAdapter extends StkProviderMultiAdapter<MyCutBean> {

    public CutAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(85));
        addItemProvider(new CutProvider());
    }

    private class CutProvider extends BaseItemProvider<MyCutBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_cut;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyCutBean bean) {
            baseViewHolder.setText(R.id.tvCutItemName, bean.getName());
            baseViewHolder.setImageResource(R.id.ivCutItemImg, bean.getImg());
            if (bean.isSelect()) {
                baseViewHolder.getView(R.id.ivCutItemSel).setVisibility(View.VISIBLE);
                baseViewHolder.setImageResource(R.id.ivCutItemImg, bean.getSelectImg());
            } else {
                baseViewHolder.getView(R.id.ivCutItemSel).setVisibility(View.INVISIBLE);
                baseViewHolder.setImageResource(R.id.ivCutItemImg, bean.getImg());
            }
        }
    }
}
